//文章请求模块
import request from "@/utils/request.js";

export const apiArticle = params => {
  return request({
    method: "GET",
    url: "/mp/v1_0/articles",
    params
  });
};

//删除文章
export const apiDeleteArticle = Articleid => {
  //Articleid=>文章id
  return request({
    //根据文章id删除文章
    method: "DELETE",
    url: `/mp/v1_0/articles/${Articleid}`
  });
};

//新建文章
export const apiAddArticle = (data, draft = false) => {
  return request({
    method: "POST",
    url: " /mp/v1_0/articles",
    params: {
      draft //是否存为草稿
    },
    data
  });
};



//获取指定文章
export const apiGetArticle = (Articleid) => {
  //Articleid=>文章id
  return request({
    method: "GET",
    url: `/mp/v1_0/articles/${Articleid}`,
  });
};

//修改文章
export const apiUpdateArticle = (Articleid, data, draft = false) => {
  //Articleid=>文章id
  return request({
    method: "PUT",
    url: `/mp/v1_0/articles/:${Articleid}`,
    params: {
      draft //是否存为草稿
    },
    data
  });
};